﻿@{
    ViewBag.Title = "Ins";
}
@section scripts
{   
    <script src="@Url.Content("~/Scripts/shared/share.js")" type="text/javascript"></script> 
    <script src="@Url.Content("~/Scripts/shared/shown.js")" type="text/javascript"></script>  
    <script src="@Url.Content("~/Scripts/common/gridlayout.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/common/export.js")" type="text/javascript"></script>
}
<body>
   <form id="form1" runat="server" method="post" style="height: 100%">
    
    <div class="mini-toolbar" style="padding:2px;border-top:0;border-left:0;border-right:0;"> 
        <table style="width:100%;">
            <tr>
                <td style="width:100%;">
                    <a class="mini-button" id="refresh" iconCls="icon-search" onclick="search" plain="true">刷新</a>
                    <a class="mini-button" id="setreck" iconCls="icon-edit" onclick="reckData" plain="true" visible="@ViewBag.reckpos">日结</a>                
                    <a class="mini-button" id="export" iconCls="icon-node" onclick="setExportExcel('datagrid1')"plain="true" visible="@ViewBag.export">导出</a>
                    <span class="separator"></span>
                    <a class="mini-button" id="close" iconCls="icon-close" onclick="CloseWindow" plain="true">关闭</a>
                </td>
            </tr>
        </table>                
    </div>
    <div class="mini-fit">
        <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" borderStyle="border:1;"pageSize="15"
            url="../System/GetReckoningDay"
            allowCellSelect="true" allowCellEdit="true" showSummaryRow="true" ondrawsummarycell="onDrawSummaryCell"
            fitColumns="false" sortMode="client">
            <div property="columns">
                <div type="checkcolumn" ></div>    
                <div field="FDate" name="FDate" width="110px" dateFormat="yyyy-MM-dd" headerAlign="center">单据日期</div> 
                <div field="FNumber" width="90" headerAlign="center">分店编码</div>
                <div field="FName" width="120" headerAlign="center">分店名称</div>
                <div field="FQty" name="FQty" width="90" headerAlign="center"align="right"numberFormat="#,0.00">合计数量</div>
                <div field="FAmount" name="FAmount" width="90" headerAlign="center"align="right"numberFormat="#,0.00">合计金额</div>
                <div field="FRemark" width="120" headerAlign="center">备注</div>    
            </div>
        </div>  
    </div>
    
    <script type="text/javascript">

        mini.parse();
        var form = new mini.Form("form1");
        var grid = mini.get("datagrid1");
        var uID = parent.window.getSystemAppID();
        var sumFields = "FQty,FAmount";

        function FormShown() {
            search();
        }

        function reckData() {
            mini.confirm("确定要进行日结吗？", "提示",
                function (action) {
                    if (action == "ok") {
                        setReckData();
                    }
                }
           );
        }

        function setReckData() {
            $.ajax({
                url: '../System/SetReckoningData',
                data: { mydata: uID },
                type: "post",
                cache: false,
                success: function (data) {
                    var mdata = mini.decode(data);
                    if (mdata.data.length > 0) {
                        search();
                        mini.showMessageBox({
                            showModal: false, width: 250, title: "提示", iconCls: "mini-messagebox-info",
                            message: mdata.data[0].FStatus, timeout: 3000, x: "right", y: "bottom"
                        });
                    }
                    else {
                        mini.alert("日结失败!");
                    }
                },
                error: function (xhr) {
                    mini.alert("异常:" + xhr.responseText);
                }
            });
        }

        function search() {
            grid.load({ mydata: uID });

            mExportDataUrl = grid.url;
            mExportDataJson = uID;//导出
        }
    </script>

    </form>
</body>